
Partial Class NewsRoom
    Inherits System.Web.UI.Page

    'Dim ddl As New DropDownList
    'Dim lnkDel As New System.Web.UI.WebControls.LinkButton
    'Dim lnkMore As New System.Web.UI.WebControls.LinkButton
    Dim dt As New Data.DataTable
    Dim i, j, k, m, count, x, y As Integer

    Protected Sub News_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
        Response.Cache.SetCacheability(HttpCacheability.NoCache)
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim f As New Globo
        f.executesql("select count (*) from posts", False)
        While f.dr.Read
            If f.dr(0) = 0 Then
                'MsgBox("No news available now..", , "!nfo")
                If Session("type") = "" Then
                    Server.Transfer("Loading.aspx")
                Else
                    Dim str As String
                    str = Left(Session("type"), 1)
                    Response.Redirect("" & str & "Profile.aspx")
                End If
            End If
        End While

        Session("pgno") = "F"
        Session("page") = "NR"
        Session("ViewMore") = False
        pnl0.Visible = False
        pnl1.Visible = False
        pnl2.Visible = False
        pnl3.Visible = False
        pnl4.Visible = False
        lnkNewest.Enabled = True
        lnkNewer.Enabled = True
        lnkOlder.Enabled = True
        lnkOldest.Enabled = True

        If Me.IsPostBack = False Then
            Dim c As New Globo
            c.executesql("select * from types", False)
            ddlNType.Items.Clear()
            ddlNType.Items.Add("All")
            While c.dr.Read = True
                ddlNType.Items.Add(c.dr(0))
            End While
            ddlNType.Items.Add("Other")
            c.dr.Close()
            Session("ispostback") = False
        Else
            Session("ispostback") = True
        End If

        If Session("type") = "" Then
            lnkProfName.Text = "Logged in as GUEST"
            lnkThemes.Enabled = False
            lnkSettings.Enabled = False
            lnkLogOut.Enabled = False
        Else
            lnkProfName.Text = "Logged in as " & Session("prim") & " (" & Session("sec") & ")"
            If Session("type") <> "buyer" Then
                lnkGo.Visible = True
                imgbtnGo.Visible = True

                If Session("type") = "admin" Then
                    lnkGo.Text = "Go to News Page.."
                ElseIf Session("type") = "user" Then
                    lnkGo.Text = "Post News.."
                End If
            End If
        End If


        '_________________________________________________________________________________________
        '#########################################################################################
        '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
        Dim ntype As String
        'Session("ntype") = LCase(ddlNType.Text)
        ''MsgBox("Session('ntype'): '" & Session("ntype") & "'", , "Session('ntype')")
        ntype = Session("ntype")
        ''MsgBox("ntype: '" & ntype & "'", , "ntype")

        'If Me.IsPostBack = False Then
        Dim a As New Globo
        'If ntype = "all" Or Session("ntype") = "" Then 'Or Session("ispostback") = True Then 'Or Session("NRload") = 0 Then
        a.executesql("select count (*) from posts", False)
        'Else
        '    a.executesql("select count (*) from posts where ntype='" & ntype & "'", False)
        'End If

        While a.dr.Read
            count = a.dr(0)
            Session("count") = count
            ''MsgBox("count = " & Session("count"), , "count")

            'If ntype <> "all" Then Session("NRload") = 0
            'If Session("ispostback") = False Then Session("NRload") = 0 Else Session("NRload") = 1
            ''MsgBox("before Session('NRload') = " & Session("NRload"), , "NRload")
            'MsgBox("sort = " & Session("sort"), , "Session('sort')")
            If Session("NRload") = 0 Or Session("sort") = True Then
                Session("start") = 0
                If Session("count") > 5 Then Session("end") = 4 Else Session("end") = Session("count") - 1
                'If ntype <> "all" Then Session("NRload") = 1 Else Session("NRload") = 0
                'If Session("ispostback") = False Then Session("NRload") = 1 Else Session("NRload") = 0
                Session("NRload") = 1
            End If
            ''MsgBox("after Session('NRload') = " & Session("NRload"), , "NRload")

            'MsgBox("Session: start/end/count = " & Session("start") & "/" & Session("end") & "; " & Session("count"), , "start/end/count")
            'MsgBox("Me.IsPostBack = " & Me.IsPostBack, , "Me.IsPostBack")


            Dim b As New Globo
            'If ntype = "all" Or Session("ntype") = "" Then 'Or Session("ispostback") = True Then 'Or Session("NRload") = 0 Then
            b.executesql("select pid, uid, header, body, dt_post, time_post, buy_status, anon from posts order by pid desc", False)
            '    'Session("NRload") = 1
            'Else
            '    b.executesql("select pid, uid, header, body, dt_post, time_post, buy_status, anon from posts where ntype='" & ntype & "' order by pid desc", False)
            'End If

            'While b.dr.Read
            dt.Load(b.dr)


            'While b.dr.Read/dt.read
            For i = Session("start") To Session("end") '0 To count - 1 
                If i < 0 Or i >= Session("count") Then Exit While 'Sub/for/while
                j = i Mod 5

                Dim pnl As Panel = CType(FindControl("pnl" & j.ToString), Panel)
                Dim lblHeader As Label = CType(FindControl("lblHeader" & j.ToString), Label)
                Dim lblBody As Label = CType(FindControl("lblBody" & j.ToString), Label)
                Dim txtBody As TextBox = CType(FindControl("txtBody" & j.ToString), TextBox)
                Dim lblPid As Label = CType(FindControl("lblPid" & j.ToString), Label)
                Dim lnkMore As LinkButton = CType(FindControl("lnkMore" & j.ToString), LinkButton)
                Dim lblPostAt As Label = CType(FindControl("lblPostAt" & j.ToString), Label)
                Dim lblStatus As Label = CType(FindControl("lblStatus" & j.ToString), Label)
                Dim lnkDel As LinkButton = CType(FindControl("lnkDel" & j.ToString), LinkButton)
                Dim icoImg As Image = CType(FindControl("icoImg" & j.ToString), Image)
                Dim icoVid As Image = CType(FindControl("icoVid" & j.ToString), Image)
                Dim strposttime As String
                Dim newsBody As String


                pnl.Visible = True
                lblPid.Text = dt.Rows(i)(0)
                lblHeader.Text = (i + 1) & ": " & dt.Rows(i)(2)
                newsBody = Left(dt.Rows(i)(3), 200)
                newsBody = Replace(newsBody, "`", vbCrLf)
                'lblBody.Text = Replace(newsBody, "`", vbCrLf)
                'txtBody.Text = Replace(newsBody, "`", vbCrLf)
                lblBody.Visible = True
                txtBody.Visible = False

                Dim c, d As New Globo
                c.executesql("select count(*) from nimage where pid='" & dt.Rows(i)(0) & "'", False)
                While c.dr.Read
                    If c.dr(0) <> 0 Then icoImg.Visible = True
                End While

                d.executesql("select count(*) from nvid where pid='" & dt.Rows(i)(0) & "'", False)
                While d.dr.Read
                    If d.dr(0) <> 0 Then icoVid.Visible = True
                End While

                If Len(dt.Rows(i)(3)) > 200 Then 'Or c1 Or d1 Then
                    If Session("type") = "" Then
                        'lblBody.Text = lblBody.Text & ".." & vbCrLf & "(to see the full news, register/login as user or buyer)"
                        'txtBody.Text = txtBody.Text & ".." & vbCrLf & "(to see the full news, register/login as user or buyer)"
                        lblBody.Text = newsBody & ".." & vbCrLf & "(to see the full news, register/login as user or buyer)"
                        txtBody.Text = newsBody & ".." & vbCrLf & "(to see the full news, register/login as user or buyer)"
                    Else
                        'lblBody.Text = lblBody.Text & ".." & vbCrLf & "(to see the full news, press ""View More"")"
                        'txtBody.Text = txtBody.Text & ".." & vbCrLf & "(to see the full news, press ""View More"")"
                        lblBody.Text = newsBody & ".." & vbCrLf & "(to see the full news, press ""View More"")"
                        txtBody.Text = newsBody & ".." & vbCrLf & "(to see the full news, press ""View More"")"
                    End If
                End If
                strposttime = dt.Rows(i)(4) & " " & dt.Rows(i)(5)

                If Session("type") = "admin" Then
                    lnkDel.Visible = True
                    lblPid.Visible = True
                End If
                If Session("type") = "user" And dt.Rows(i)(1) = Session("prim") Then lnkDel.Visible = True
                If Session("type") = "" Then
                    lnkMore.Text = "Register Now to view more!"
                    lnkMore.Font.Italic = True
                End If

                If dt.Rows(i)(6) = "Available" Then
                    lblStatus.Text = "News available for sale. Bid now!"
                    lblStatus.ForeColor = Drawing.Color.Green
                ElseIf dt.Rows(i)(6) = "Sold" Then
                    lblStatus.Text = "News already sold!"
                    lblStatus.ForeColor = Drawing.Color.Brown
                End If

                If dt.Rows(i)(7) = False Then
                    lblPostAt.Text = "Posted by '" & dt.Rows(i)(1) & "' on " & strposttime
                    If Session("type") = "user" And lnkDel.Visible = True Then lblPostAt.Text = "Posted by you on " & strposttime
                ElseIf dt.Rows(i)(7) = "True" Then
                    lblPostAt.Text = "Posted anonymously on " & strposttime
                    If Session("type") = "admin" Then lblPostAt.Text = "Posted by '" & dt.Rows(i)(1) & "' [anonymously] on " & strposttime
                    If Session("type") = "user" And dt.Rows(i)(1) = Session("prim") Then lblPostAt.Text = "Posted by you [anonymously] on " & strposttime
                End If
            Next i
            'End While
            'End If
            'End While
        End While



        '########################################################### Navigation Links
        If Session("count") <= 5 Then
            lnkNewest.Enabled = False
            lnkNewer.Enabled = False
            lnkOlder.Enabled = False
            lnkOldest.Enabled = False
        Else
            If Session("start") = 0 Then
                lnkNewest.Enabled = False
                lnkNewer.Enabled = False
            ElseIf Session("end") = Session("count") - 1 Then
                lnkOlder.Enabled = False
                lnkOldest.Enabled = False
            End If
        End If



        '################################################################## PAGE Nos.
        Dim last As Integer
        last = Math.Floor((Session("count") - 1) / 5) + 1
        Session("last") = last

        ''fixed page number: 1-5, 6-10 etc
        If Session("pgno") = "F" Then
            For m = 1 To 5
                Dim lnk As LinkButton = CType(FindControl("lnk" & m.ToString), LinkButton)
                lnk.Text = (5 * Math.Floor(Session("start") / 25)) + m
                If Session("count") - 1 < (lnk.Text - 1) * 5 Then lnk.Visible = False Else lnk.Visible = True
                If lnk.Text = (Session("start") / 5) + 1 Then lnk.BorderWidth = 1 Else lnk.BorderWidth = 0
            Next
            If lnk5.Text + 1 <= Session("last") And lnk5.Visible = True Then lnk6.Visible = True Else lnk6.Visible = False
            If lnk1.Text - 5 < 1 Then lnk0.Visible = False Else lnk0.Visible = True
        End If

        'rotating page numbers (mid=current): 1-5; 2-6
        If Session("pgno") = "R" Then
            lnk3.BorderWidth = 1
            lnk3.Text = Session("start") / 5 + 1
            If lnk5.Text + 5 > Session("last") Then
                lnk3.Text = last
                lnk6.Visible = False
            End If

            If lnk3.Text > 2 Then
                lnk1.Text = (lnk3.Text - 2)
                lnk1.Visible = True
            Else
                lnk1.Visible = False
            End If
            If lnk1.Text - 5 < 1 Then
                lnk0.Visible = False
                lnk3.Text = 1
            End If

            If lnk3.Text > 1 Then
                lnk2.Text = (lnk3.Text - 1)
                lnk2.Visible = True
            Else
                lnk2.Visible = False
            End If

            If lnk3.Text <= (last - 1) Then
                lnk4.Text = (lnk3.Text + 1)
                lnk4.Visible = True
            Else
                lnk4.Visible = False
            End If

            If lnk3.Text <= (last - 2) Then
                lnk5.Text = (lnk3.Text + 2)
                lnk5.Visible = True
            Else
                lnk5.Visible = False
            End If
        End If

        Session("sort") = False
        'MsgBox("Me.IsPostBack = " & Me.IsPostBack, , "Me.IsPostBack")
    End Sub

    Protected Sub lnkMore0_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkMore0.Click
        If Session("type") = "" Then
            Response.Redirect("SignUp.aspx")
            Exit Sub
        End If

        Session("ViewMore") = True
        Session("NRload") = 0
        Session("pid") = lblPid0.Text
        Response.Redirect("NewsDetails.aspx")
    End Sub

    Protected Sub lnkMore1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkMore1.Click
        If Session("type") = "" Then
            Response.Redirect("SignUp.aspx")
            Exit Sub
        End If

        Session("ViewMore") = True
        Session("NRload") = 0
        Session("pid") = lblPid1.Text
        Response.Redirect("NewsDetails.aspx")
    End Sub

    Protected Sub lnkMore2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkMore2.Click
        If Session("type") = "" Then
            Response.Redirect("SignUp.aspx")
            Exit Sub
        End If

        Session("ViewMore") = True
        Session("NRload") = 0
        Session("pid") = lblPid2.Text
        Response.Redirect("NewsDetails.aspx")
    End Sub

    Protected Sub lnkMore3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkMore3.Click
        If Session("type") = "" Then
            Response.Redirect("SignUp.aspx")
            Exit Sub
        End If

        Session("ViewMore") = True
        Session("NRload") = 0
        Session("pid") = lblPid3.Text
        Response.Redirect("NewsDetails.aspx")
    End Sub

    Protected Sub lnkMore4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkMore4.Click
        If Session("type") = "" Then
            Response.Redirect("SignUp.aspx")
            Exit Sub
        End If

        Session("ViewMore") = True
        Session("NRload") = 0
        Session("pid") = lblPid4.Text
        Response.Redirect("NewsDetails.aspx")
    End Sub

    Protected Sub lnkDel0_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkDel0.Click
        pnl0.Enabled = False
        pnlDel0.Visible = True
    End Sub

    Protected Sub lnkDel1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkDel1.Click
        pnl1.Enabled = False
        pnlDel1.Visible = True
    End Sub

    Protected Sub lnkDel2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkDel2.Click
        pnl2.Enabled = False
        pnlDel2.Visible = True
    End Sub

    Protected Sub lnkDel3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkDel3.Click
        pnl3.Enabled = False
        pnlDel3.Visible = True
    End Sub

    Protected Sub lnkDel4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkDel4.Click
        pnl4.Enabled = False
        pnlDel4.Visible = True
    End Sub

    Protected Sub btnY0_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnY0.Click
        Dim a As New Globo
        a.executesql("delete from posts where pid='" & lblPid0.Text & "'", True)

        Dim b As New Globo
        b.executesql("delete from nimage where pid='" & lblPid0.Text & "'", True)

        Dim c As New Globo
        c.executesql("delete from nvid where pid='" & lblPid0.Text & "'", True)

        Session("NRload") = 0
        Response.Redirect("NewsRoom.aspx")
    End Sub

    Protected Sub btnY1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnY1.Click
        Dim a As New Globo
        a.executesql("delete from posts where pid='" & lblPid1.Text & "'", True)

        Dim b As New Globo
        b.executesql("delete from nimage where pid='" & lblPid1.Text & "'", True)

        Dim c As New Globo
        c.executesql("delete from nvid where pid='" & lblPid1.Text & "'", True)

        Session("NRload") = 0
        Response.Redirect("NewsRoom.aspx")
    End Sub

    Protected Sub btnY2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnY2.Click
        Dim a As New Globo
        a.executesql("delete from posts where pid='" & lblPid2.Text & "'", True)

        Dim b As New Globo
        b.executesql("delete from nimage where pid='" & lblPid2.Text & "'", True)

        Dim c As New Globo
        c.executesql("delete from nvid where pid='" & lblPid2.Text & "'", True)

        Session("NRload") = 0
        Response.Redirect("NewsRoom.aspx")
    End Sub

    Protected Sub btnY3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnY3.Click
        Dim a As New Globo
        a.executesql("delete from posts where pid='" & lblPid3.Text & "'", True)

        Dim b As New Globo
        b.executesql("delete from nimage where pid='" & lblPid3.Text & "'", True)

        Dim c As New Globo
        c.executesql("delete from nvid where pid='" & lblPid3.Text & "'", True)

        Session("NRload") = 0
        Response.Redirect("NewsRoom.aspx")
    End Sub

    Protected Sub btnY4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnY4.Click
        Dim a As New Globo
        a.executesql("delete from posts where pid='" & lblPid4.Text & "'", True)

        Dim b As New Globo
        b.executesql("delete from nimage where pid='" & lblPid4.Text & "'", True)

        Dim c As New Globo
        c.executesql("delete from nvid where pid='" & lblPid4.Text & "'", True)

        Session("NRload") = 0
        Response.Redirect("NewsRoom.aspx")
    End Sub

    Protected Sub btnN0_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnN0.Click
        pnlDel0.Visible = False
        pnl0.Enabled = True
    End Sub

    Protected Sub btnN1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnN1.Click
        pnlDel1.Visible = False
        pnl1.Enabled = True
    End Sub

    Protected Sub btnN2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnN2.Click
        pnlDel2.Visible = False
        pnl2.Enabled = True
    End Sub

    Protected Sub btnN3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnN3.Click
        pnlDel3.Visible = False
        pnl3.Enabled = True
    End Sub

    Protected Sub btnN4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnN4.Click
        pnlDel4.Visible = False
        pnl4.Enabled = True
    End Sub

    Protected Sub lnkGo_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkGo.Click
        If Session("type") = "admin" Then
            Response.Redirect("NewsDetails.aspx")
        ElseIf Session("type") = "user" Then
            Response.Redirect("Posts.aspx")
        End If
    End Sub

    Protected Sub imgbtnGo_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgbtnGo.Click
        If Session("type") = "admin" Then
            Response.Redirect("NewsDetails.aspx")
        ElseIf Session("type") = "user" Then
            Response.Redirect("Posts.aspx")
        End If
    End Sub

    Protected Sub lnkNewest_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkNewest.Click
        Session("start") = 0
        If Session("count") > 5 Then Session("end") = 4 Else Session("end") = Session("count") - 1
        ''MsgBox("Session: start/end/count = " & Session("start") & "/" & Session("end") & "; " & Session("end"), , "start/end/count")

        Call Page_Load(sender, e)
    End Sub

    Protected Sub lnkNewer_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkNewer.Click
        Dim a As Integer
        a = Math.Floor(Session("count") / 5) * 5

        Session("start") = Session("start") - 5
        If Session("end") = Session("count") - 1 Then Session("end") = (a - 1) Else Session("end") = Session("end") - 5
        ''MsgBox("Session: start/end/count = " & Session("start") & "/" & Session("end") & "; " & Session("end"), , "start/end/count")

        Call Page_Load(sender, e)
    End Sub

    Protected Sub lnkOlder_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkOlder.Click
        Session("start") = Session("start") + 5
        If Session("count") - Session("end") > 5 Then Session("end") = Session("end") + 5 Else Session("end") = Session("count") - 1
        ''MsgBox("Session: start/end/count = " & Session("start") & "/" & Session("end") & "; " & Session("end"), , "start/end/count")

        Call Page_Load(sender, e)
    End Sub

    Protected Sub lnkOldest_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkOldest.Click
        'MsgBox("Session: start/end/count = " & Session("start") & "/" & Session("end") & "; " & Session("end"), , "BEFORE start/end/count")
        Dim a As Integer
        a = Math.Floor((Session("count") - 1) / 5) * 5
        'MsgBox(a)

        If Session("count") > 5 Then Session("start") = a 'Else Session("start") = 0
        Session("end") = Session("count") - 1
        'MsgBox("Session: start/end/count = " & Session("start") & "/" & Session("end") & "; " & Session("end"), , "AFTER start/end/count")

        Call Page_Load(sender, e)
    End Sub

    Protected Sub ddlNType_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlNType.SelectedIndexChanged
        'Session("NRload") = 0
        'Session("start") = 0
        'If Session("count") > 5 Then Session("end") = 4 Else Session("end") = Session("count") - 1
    End Sub

    Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        Session("NRload") = 0
        Session("ntype") = LCase(ddlNType.Text)
        Session("sort") = True
        Session("start") = 0
        If Session("count") > 5 Then Session("end") = 4 Else Session("end") = Session("count") - 1
        'MsgBox("Session: start/end/count [search] = " & Session("start") & "/" & Session("end") & "; " & Session("end"), , "start/end/count")

        Call Page_Load(sender, e)
        'Call Page_Load(sender, e)
        'Call Page_Load(sender, e)
    End Sub

    Protected Sub lnk1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnk1.Click
        Session("start") = (lnk1.Text - 1) * 5
        Session("end") = Session("start") + 4
        If Session("end") > Session("count") - 1 Then Session("end") = Session("count") - 1
        'MsgBox("Session: start/end/count = " & Session("start") & "/" & Session("end") & "; " & Session("end"), , "start/end/count")

        Call Page_Load(sender, e)
    End Sub

    Protected Sub lnk2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnk2.Click
        Session("start") = (lnk2.Text - 1) * 5
        Session("end") = Session("start") + 4
        If Session("end") > Session("count") - 1 Then Session("end") = Session("count") - 1
        'MsgBox("Session: start/end/count = " & Session("start") & "/" & Session("end") & "; " & Session("end"), , "start/end/count")

        Call Page_Load(sender, e)
    End Sub

    Protected Sub lnk3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnk3.Click
        Session("start") = (lnk3.Text - 1) * 5
        Session("end") = Session("start") + 4
        If Session("end") > Session("count") - 1 Then Session("end") = Session("count") - 1
        'MsgBox("Session: start/end/count = " & Session("start") & "/" & Session("end") & "; " & Session("end"), , "start/end/count")

        Call Page_Load(sender, e)
    End Sub

    Protected Sub lnk4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnk4.Click
        Session("start") = (lnk4.Text - 1) * 5
        Session("end") = Session("start") + 4
        If Session("end") > Session("count") - 1 Then Session("end") = Session("count") - 1
        'MsgBox("Session: start/end/count = " & Session("start") & "/" & Session("end") & "; " & Session("end"), , "start/end/count")

        Call Page_Load(sender, e)
    End Sub

    Protected Sub lnk5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnk5.Click
        Session("start") = (lnk5.Text - 1) * 5
        Session("end") = Session("start") + 4
        If Session("end") > Session("count") - 1 Then Session("end") = Session("count") - 1
        'MsgBox("Session: start/end/count = " & Session("start") & "/" & Session("end") & "; " & Session("end"), , "start/end/count")

        Call Page_Load(sender, e)
    End Sub

    Protected Sub lnk0_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnk0.Click
        'If lnk0.Text - 5 < 0 Then Exit Sub

        If Session("pgno") = "F" Then
            For m = 1 To 5
                Dim lnk As LinkButton = CType(FindControl("lnk" & m.ToString), LinkButton)
                lnk.Text = lnk.Text - 5 '(5 * Math.Floor(Session("start") / 25)) + m
                If Session("count") - 1 < (lnk.Text - 1) * 5 Then lnk.Enabled = False 'Else lnk.Enabled = False
                'MsgBox(lnk.Text)
            Next
            Call lnk5_Click(sender, e)
        ElseIf Session("pgno") = "R" Then

        End If
    End Sub

    Protected Sub lnk6_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnk6.Click
        'If lnk5.Text + 5 > Session("last") Then Exit Sub

        If Session("pgno") = "F" Then
            For m = 1 To 5
                Dim lnk As LinkButton = CType(FindControl("lnk" & m.ToString), LinkButton)
                lnk.Text = lnk.Text + 5 '(5 * Math.Floor(Session("start") / 25)) + m
                If Session("count") - 1 < (lnk.Text - 1) * 5 Then lnk.Enabled = False 'Else lnk.Enabled = False
                'MsgBox(lnk.Text)
            Next
            Call lnk1_Click(sender, e)
        ElseIf Session("pgno") = "R" Then

        End If

    End Sub

    '_________________________________________________________________________________________________________________________________
    '#################################################################################################################################
    Protected Sub lnkProfName_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkProfName.Click
        If Session("type") = "" Then
            Exit Sub
        Else
            Dim str As String
            str = UCase(Left(Session("type"), 1))
            Response.Redirect("" & str & "Profile.aspx")
        End If
    End Sub

    'Protected Sub lnkQuery_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkQuery.Click
    '    Response.Redirect("Query.aspx")
    'End Sub

    Protected Sub lnkThemes_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkThemes.Click
        Response.Redirect("Themes.aspx")
    End Sub

    Protected Sub lnkSettings_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkSettings.Click
        Response.Redirect("Settings.aspx")
    End Sub

    Protected Sub lnkLogOut_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkLogOut.Click
        Server.Transfer("Loading.aspx")
    End Sub

    '_____________________________________________________________________________________________________________
    '*************************************************************************************************************
    Protected Sub lnkAboutUs_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkAboutUs.Click
        Response.Redirect("AboutUs.aspx")
    End Sub

    Protected Sub lnkTermCond_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkTermCond.Click
        Response.Redirect("TermsConditions.aspx")
    End Sub

    Protected Sub lnkContactUs_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkContactUs.Click
        Response.Redirect("ContactUs.aspx")
    End Sub

    Protected Sub lnkFAQs_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkFAQs.Click
        Response.Redirect("FAQs.aspx")
    End Sub

    Protected Sub lnkFeedback_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkFeedback.Click
        Response.Redirect("Feedback.aspx")
    End Sub
End Class